import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Directory {
    private String name;
    private Date createDate;
    Mode mode;
    private String owner;
    private String group;
    private Directory parent;
    private int size;
    List<Directory> subDirList = new ArrayList<>();
    List<File> fileList = new ArrayList<>();

    Directory(String name, Directory parent, String owner, String group){
        this.name = name; // file name
        this.owner = owner;
        this.group = group;
        this.createDate = new Date(); // date
        this.parent = parent;
        int[] modeCode = { 7, 6, 1 };//Mode of access is initiated as "7,6,1"
        this.mode = new Mode(modeCode);
        this.size = 0;
    }

    public String getName() {
        return name;
    }

    public Mode getMode() {
        return mode;
    }

    public Directory getParent() {
        return parent;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String detail() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return "f" + mode.getString() + "  " + File.mulDigitStr(owner, 15, ' ') + "   " + File.mulDigitStr(group, 15, ' ') + "   "
                + File.mulDigitStr(Integer.toString(size), 10, ' ') + "   " + File.mulDigitStr(format.format(createDate), 20, ' ')
                + "   " + name;
    }


    @Override
    public String toString() {
        return name+"/";
    }
}